<template>
    <div>
        <h2>排房添加</h2>
        <table class="table  table-bordered">
            <tbody>
                <tr>
                    <td>房型名称</td>
                    <td>
                        <input type="text" v-model="model.Name">
                    </td>
                </tr>


                <tr>
                    <td>房号名称</td>
                    <td>
                        <input type="text" v-model="model.Number">
                    </td>
                </tr>


                <tr>
                    <td></td>
                    <td>
                        <input type="button" class="btn btn-success" value="添加" @click="ok">
                    </td>
                </tr>

            </tbody>


        </table>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import axios from 'axios';
const route = useRoute();
const router = useRouter();

//添加
let model = reactive({
    "Name": '',
    "Number": '',

})



//添加
const ok = () => {

    axios({

        url: 'https://localhost:7259/api/HouseType/PeiFangAdd',
        method: 'post',
        data: model,
    })

        .then((res) => {
            console.log(res);


            if (res.data > 0) {
                alert("添加成功");
             router.push('/PeiFangList')
            }
            else {
                alert("添加失败");
                return;
            }
        })

        .catch((ree) => {
            console.log(ree);
        })



}







</script>

<style scoped></style>